package com.bbs.service;

import java.util.List;

import com.bbs.dao.MessageDao;
import com.bbs.entity.Article;
import com.bbs.entity.Message;
import com.bbs.entity.User;
import com.bbs.util.DateUtil;
import com.bbs.util.Page;

public class MessageService {
	private MessageDao md = new MessageDao();

	public void sendMessage(User user, Article a,String content) {
		String date = DateUtil.getNow();
		md.save(user,a,content,date);
	}

	/**
	 * 通过用户id找到未读的消息
	 * @param id
	 * @return
	 */
	public List<Message> findNoReadByUid(int id,Page page) {
		return md.findNoReadByUid(id,page);
	}

	public void setRead() {
		new MessageDao().update();
	}

	public int getNoReadCountByuid(int id) {
		return new MessageDao().getNoReadCountByuid(id);
	}
}
